<%@page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge"/>
  <title>韩顺平教育-家居网购</title>
  <base href="<%=request.getContextPath()%>/">
  <!-- 移动端适配 -->
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
  <link rel="stylesheet" href="assets/css/vendor/vendor.min.css"/>
  <link rel="stylesheet" href="assets/css/plugins/plugins.min.css"/>
  <link rel="stylesheet" href="assets/css/style.min.css">
  <style type="text/css">
    #pic {
      position: relative;
    }
    input[type="file"] {
      position: absolute;
      left: 0;
      top: 0;
      height: 180px;
      opacity: 0;
      cursor: pointer;
    }
  </style>
  <script src="script/jquery-3.6.0.min.js"></script>
  <script type="text/javascript">
    function prev(event) {
      //获取展示图片的区域
      var img = document.getElementById("preView");
      //获取文件对象
      var file = event.files[0];
      //获取文件阅读器: Js的一个类, 直接使用即可
      var reader = new FileReader();
      reader.readAsDataURL(file);
      reader.onload = function () {
        //给img的src设置图片url
        img.setAttribute("src", this.result)
      }
    }
    window.onload = function () {
      $("input[type='submit']")[0].onclick = function () {
        if ($("input[name='name']").val() == "" || $("input[name='name']").val() == null) {
          alert("请输入家居名");
          return false;
        } else if ($("input[name='business']").val() == "" || $("input[name='business']").val() == null) {
          alert("请输入商家名");
          return false;
        } else if ($("input[name='price']").val() == "" || $("input[name='price']").val() == null) {
          alert("请输入价格");
          return false;
        } else if ($("input[name='saleNum']").val() == "" || $("input[name='saleNum']").val() == null) {
          alert("请输入销量");
          return false;
        } else if ($("input[name='inventory']").val() == "" || $("input[name='inventory']").val() == null) {
          alert("请输入库存");
          return false;
        }else if (!/^\d+(\.\d+)?$/.test($("input[name='price']").val())) {
          alert("价格格式不对");
          return false;
        } else if (!/^\d+$/.test($("input[name='saleNum']").val())) {
          alert("销量格式不对");
          return false;
        } else if (!/^\d+$/.test($("input[name='inventory']").val())) {
          alert("库存格式不对");
          return false;
        }
      }
    }
  </script>
</head>

<body>
<!-- Header Area start  -->
<div class="header section">
  <!-- Header Top  End -->
  <!-- Header Bottom  Start -->
  <div class="header-bottom d-none d-lg-block">
    <div class="container position-relative">
      <div class="row align-self-center">
        <!-- Header Logo Start -->
        <div class="col-auto align-self-center">
          <div class="header-logo">
            <a href="index.jsp"><img src="assets/images/logo/logo.png" alt="Site Logo"/></a>
          </div>
        </div>
        <!-- Header Logo End -->

        <!-- Header Action Start -->
        <div class="col align-self-center">
          <div class="header-actions">

            <!-- Single Wedge Start -->
            <div class="header-bottom-set dropdown">
              <a href="#">家居管理</a>
            </div>
            <div class="header-bottom-set dropdown">
              <a href="orderServlet?action=listOrderByMemberId&memberId=${sessionScope.member.id}">订单管理</a>
            </div>
          </div>
        </div>
        <!-- Header Action End -->
      </div>
    </div>
  </div>
  <!-- Header Bottom  End -->
  <!-- Header Bottom  Start 手机端的header -->
  <div class="header-bottom d-lg-none sticky-nav bg-white">
    <div class="container position-relative">
      <div class="row align-self-center">
        <!-- Header Logo Start -->
        <div class="col-auto align-self-center">
          <div class="header-logo">
            <a href="index.jsp"><img width="280px" src="assets/images/logo/logo.png" alt="Site Logo"/></a>
          </div>
        </div>
        <!-- Header Logo End -->
      </div>
    </div>
  </div>
  <!-- Main Menu Start -->
  <div style="width: 100%;height: 50px;background-color: black"></div>
  <!-- Main Menu End -->
</div>
<!-- Cart Area Start -->
<div class="cart-main-area pt-100px pb-100px">
  <div class="container">
    <h3 class="cart-page-title">家居后台管理-添加家居</h3>
    <div class="row">
      <div class="col-lg-12 col-md-12 col-sm-12 col-12">
        <form action="manage/furnServlet?action=add&pageNo=${param.pageNo}" method="post" enctype="multipart/form-data">
          <input type="hidden" value="add" name="action" />
          <input type="hidden" value="${param.pageNo}" name="pageNo">
          <div class="table-content table-responsive cart-table-content">
            <table>
              <thead>
              <tr>
                <th>图片</th>
                <th>家居名</th>
                <th>商家</th>
                <th>价格</th>
                <th>销量</th>
                <th>库存</th>
                <th>操作</th>
              </tr>
              </thead>
              <tbody>
              <tr>
                <td class="product-thumbnail">
                  <div id="pic">
                    <img class="img-responsive ml-3" src="${requestScope.furn.imagePath}"
                         alt="123" id="preView">
                    <input type="file" name="imagePath" id="" value="${requestScope.furn.imagePath}"
                           onchange="prev(this)"/>
                  </div>
                </td>
                <td class="product-name"><input name="name" style="width: 60%" type="text" value="Name"/></td>
                <td class="product-name"><input name="business" style="width: 90%" type="text" value="蚂蚁家居"/></td>
                <td class="product-price-cart"><input name="price" style="width: 90%" type="text" value="60.00"/></td>
                <td class="product-quantity">
                  <input name="saleNum" style="width: 90%" type="text" value="100"/>
                </td>
                <td class="product-quantity">
                  <input name="inventory" style="width: 90%" type="text" value="80"/>
                </td>
                <td>
                  <!--                                    <a href="#"><i class="icon-pencil"></i></a>-->
                  <!--                                    <a href="#"><i class="icon-close"></i></a>-->
                  <input type="submit" style="width: 90%;background-color: silver;border: silver;border-radius: 20%;" value="添加家居"/>
                </td>
              </tr>
              </tbody>
            </table>
          </div>
        </form>
        <span class="errorMsg"
              style="float: right; font-weight: bold; color: lightgray; font-size: 20pt; margin-left: 10px;">${msg}</span>
      </div>
    </div>
  </div>
</div>
<!-- Cart Area End -->

<!-- Footer Area Start -->
<div class="footer-area">
  <div class="footer-container">
    <div class="footer-top">
      <div class="container">
        <div class="row">
          <!-- Start single blog -->
          <!-- End single blog -->
          <!-- Start single blog -->
          <div class="col-md-6 col-sm-6 col-lg-3 mb-md-30px mb-lm-30px" data-aos="fade-up"
               data-aos-delay="400">
            <div class="single-wedge">
              <h4 class="footer-herading">信息</h4>
              <div class="footer-links">
                <div class="footer-row">
                  <ul class="align-items-center">
                    <li class="li"><a class="single-link" href="about.jsp">关于我们</a></li>
                    <li class="li"><a class="single-link" href="#">交货信息</a></li>
                    <li class="li"><a class="single-link" href="privacy-policy.jsp">隐私与政策</a></li>
                    <li class="li"><a class="single-link" href="#">条款和条件</a></li>
                    <li class="li"><a class="single-link" href="#">制造</a></li>
                  </ul>
                </div>
              </div>
            </div>
          </div>
          <!-- End single blog -->
          <!-- Start single blog -->
          <div class="col-md-6 col-lg-2 col-sm-6 mb-lm-30px" data-aos="fade-up" data-aos-delay="600">
            <div class="single-wedge">
              <h4 class="footer-herading">我的账号</h4>
              <div class="footer-links">
                <div class="footer-row">
                  <ul class="align-items-center">
                    <li class="li"><a class="single-link" href="my-account.jsp">我的账号</a>
                    </li>
                    <li class="li"><a class="single-link" href="cart.jsp">我的购物车</a></li>
                    <li class="li"><a class="single-link" href="login.jsp">登录</a></li>
                    <li class="li"><a class="single-link" href="wishlist.jsp">感兴趣的</a></li>
                    <li class="li"><a class="single-link" href="checkout.jsp">结账</a></li>
                  </ul>
                </div>
              </div>
            </div>
          </div>
          <!-- End single blog -->
          <!-- Start single blog -->
          <div class="col-md-6 col-lg-3" data-aos="fade-up" data-aos-delay="800">

          </div>
          <!-- End single blog -->
        </div>
      </div>
    </div>
    <div class="footer-bottom">
      <div class="container">
        <div class="row flex-sm-row-reverse">
          <div class="col-md-6 text-right">
            <div class="payment-link">
              <img src="#" alt="">
            </div>
          </div>
          <div class="col-md-6 text-left">
            <p class="copy-text">Copyright &copy; 2021 韩顺平教育~</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- Footer Area End -->
<script src="assets/js/vendor/vendor.min.js"></script>
<script src="assets/js/plugins/plugins.min.js"></script>
<!-- Main Js -->
<script src="assets/js/main.js"></script>
</body>
</html>
